//---------------------------------------------------------------------------
class ServerControl;
#ifndef servercontrolH
#define servercontrolH
#include "structs.h"
#include "player_info.h"
#include "utils.h"
//#include "Player_Window.h"

#define PLAYERADDY (Static_Player_Header*)0x4029CE90
#define OBJECTADDY (Object_Table_Header*)0x4005062C
#define ALTERADDY (Alter_Player*) 0x006C7ACA
#define MACHINEADDY (MachineInfo*) 0x006C7CD8
#define GSERVERADDY (GlobalServer*) 0x006C78E0

#define BLUE 1
#define RED 0

ServerControl* Server();
void SetServer(ServerControl* server);
//---------------------------------------------------------------------------

// params: arg container of strings that compose the command.
// returns: success/fail : 1,-1
typedef playerindex (*CmdFunc)(ArgContainer);

// The servercontrol is just for an easier interface to the ingame things in memory, particularly players
class ServerControl
{
public:
	// Custom Command stuff (Later, may become seperate)
	map<string, CmdFunc> CustomCommands; // <command-keyword, function>
	bool debug;
	void AddCustomCommand(string, CmdFunc);
	playerindex DoCustomCommand(string); // attempts to execute a given command. -1=no matching command found. 0 = cmd failed. 1=cmd succeeded.

	// Player stuff
	Static_Player_Header* PlayerHeader;
	Object_Table_Header* ObjectTableHeader;
	Alter_Player* alterplayers;
	MachineInfo* machinelist;
	GlobalServer* globalserver;

	// Server Stuff.
	//ban_entry* banlist;
	void ExecCmd(const char* cmd);
	void Print(int, const char*);


	ServerControl(); // defaults to the #DEFINED addresses
	ServerControl(Static_Player_Header* pl_head, Object_Table_Header* obj_head, Alter_Player* alt_pl, MachineInfo* machine_list); // , ban_entry* ban_list);

	Static_Player* GetPlayer(playerindex Pl_Index);	// get a player pointer.	(does return NULL on bad player)
	MachineInfo* GetMachine(playerindex pl_ind);	// (does return NULL on bad player)
	string GetPlayerName(playerindex Pl_Index);
	string GetPlayerHash(playerindex pl_ind);
	string GetMapName();
	string GetGametypeName();
	string GetServerName();
	bool IsOn(playerindex pl_ind);
	bool IsSpawned(playerindex pl_ind);
	ABiped* GetBiped(playerindex Pl_Index);			// Makes it easy to get the MC (gives NULL if player not spawned)
	AWeapon* GetWeapon(playerindex pl_ind);

	D3DXVECTOR3 GetCoord(playerindex pl_ind);
	void SetCoord(playerindex pl_ind, D3DXVECTOR3 coord);
	void SetAmmo(playerindex pl_ind, unsigned short ammo);

	void SetTeam(playerindex pl_ind, toggle team); // -1 toggles, 0 or 1 just set
};

#endif
